package com.ddone.exception;

import com.ddone.model.vo.ResultCodeEnum;
import lombok.Getter;
import lombok.ToString;

import java.io.Serializable;

/**
 * @author ddone
 * @date 2024/3/27-18:50
 */
@ToString
@Getter
public class AuthManagerException extends RuntimeException implements Serializable {
    private static final long serialVersionUID = 4786241555414600755L;

    private Integer code;

    private String message;

    /**
     * 通过状态码和错误消息创建异常对象
     * @param code 异常Code
     * @param message 异常消息
     */
    public AuthManagerException(Integer code,String message){
        super(message);
        this.code = code;
        this.message = message;
    }

    /**
     * 接收枚举类型对象
     * @param resultCodeEnum 异常Code 枚举
     */
    public AuthManagerException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
        this.message = resultCodeEnum.getMessage();
    }

    public AuthManagerException(Integer code){
        this.code = code;
    }

}
